package ReentrantLock;

import java.util.concurrent.locks.LockSupport;

public class Test {
    static String[] a = {"a","b","c","d"};
    static String[] b = {"1","2","3","4"};
    static Thread at;
    static Thread bt;

    static Object o = new Object();
    public static void main(String[] args) {
        at = new Thread(()->{
            for (int i = 0; i < a.length; i++) {

                System.err.println(a[i]);
                LockSupport.unpark(bt);
                LockSupport.park();
//                synchronized (o){
//                    System.err.println(a[i]);
//                    o.notify();
//                    try {
//                        o.wait();
//                    } catch (InterruptedException e) {
//                        throw new RuntimeException(e);
//                    }
//                }


            }
        });

        bt = new Thread(()->{
            for (int i = 0; i < b.length; i++) {
                LockSupport.park();
                System.err.println(b[i]);
                LockSupport.unpark(at);
//               synchronized (o){
//                   try {
//                       o.wait();
//                   } catch (InterruptedException e) {
//                       throw new RuntimeException(e);
//                   }
//                   System.err.println(b[i]);
//                   o.notify();
//               }


            }
        });
        bt.start();
        at.start();

    }
}
